/**
 * @description: 数据看板 - echart 图表接口
 */

const Router = require("koa-router");
const router = new Router();

// 模拟一个 电量统计 echart 图表数据
const chartData = {
  list: [
    {
      name: "充电量",
      data: [20, 50, 30, 70, 60, 80, 40, 60, 50],
    },
    {
      name: "充电时长",
      data: [40, 60, 50, 80, 70, 90, 60, 70, 80],
    },
    {
      name: "充电功率",
      data: [30, 40, 60, 50, 70, 20, 30, 40, 60],
    },
  ],
};

// 模拟一个 能源统计 echart 图表数据
const chartData2 = {
  list: [
    { value: 35, name: "充电桩" },
    { value: 30, name: "充电站" },
    { value: 25, name: "充电杆" },
  ],
};

// 模拟一个 设备总览 echart 图表数据
const chartData3 = {
  list: [42, 30, 200, 350, 500, 180],
};

// 模拟一个销售额 echart 图表数据
const sales = {
  list: [
    {
      name: "销售额",
      data: [120, 200, 150, 80, 70, 110, 130],
    },
    {
      name: "访问量",
      data: [30, 50, 40, 20, 10, 60, 70],
    },
  ],
};

// 接口：GET /blocks - 电量统计
router.get("/chartData", (ctx) => {
  ctx.body = {
    code: 200,
    data: chartData,
  };
});

// 接口：GET /energy - 能源统计
router.get("/energy", (ctx) => {
  ctx.body = {
    code: 200,
    data: chartData2,
  };
});

// 接口：GET /deviceOverview - 设备总览
router.get("/deviceOverview", (ctx) => {
  ctx.body = {
    code: 200,
    data: chartData3,
  };
});

// 接口：GET /sales - 销售额
router.get("/sales", (ctx) => {
  ctx.body = {
    code: 200,
    data: sales,
  };
});

module.exports = router;
